import http from '@/utils/http'
import {DictDataResp} from './types/dict'
import type { Options } from '@/types/global';
/**
 * 查询请求体
 */
export interface QueryRequest {
    name?: string;
    dictId?: number;
    code?: string
}

/**
 * 分页请求体
 */
export interface PageQueryRequest extends QueryRequest, PageQuery {
}

/**
 * 查询响应
 */
export interface QueryResponse extends DictDataResp {
}



/**
 * 更新请求体
 */
export interface UpdateRequest {
    id?: number;
    dict_id?: number,
    sort?: number;
    name?: string;
    code?: string;
    note?: string;
}


/**
 * 查询列表(分页)
 */
export function getList(params: PageQueryRequest) {
    return http.get<PageRes<QueryResponse[]>>('/admin/dictData/index', params)
}

/**
 * 通过 id 新增更新数据
 */
export function updateRows(request: UpdateRequest) {
    return http.put('/admin/dictData/edit', request);
}

/**
 * 通过 id 删除数据
 */
export function deleteRows(id: number) {
    return http.post('/admin/dictData/delete', {id})
}


/**
 * 字典配置值选项查询响应
 */
export interface DictValueOptionsQueryResponse extends Options {
}

/**
 * 查询字典配置值
 */
export function getDictValueList(keys: string[]) {
    return http.post<PageRes<DictValueOptionsQueryResponse[]>>('/admin/dictData/valueList', {keys})
}


